# -*- coding:utf-8 -*-
# @FileName  :per_batch_query.py
# @Time      :2020/12/10 16:14
# @Author    :Zhoujirong
# @Desc      :
import os
from conf.settings import CASE_DATA_PATH
from common.http_request import Request
from biz.support.urls import ServerUrl

class EntBatchQueryRequest:
    @classmethod
    def download(cls, cookie):
        req = Request(ServerUrl.ent_batch_query_download_url, headers=cookie)
        return req.get_download()

    @classmethod
    def upload(cls,file1,file2,cookie):
        file_data = {
            'file': open(os.path.join(CASE_DATA_PATH, '%s') % file1, 'rb')
        }
        data = {
            'file':file2
        }
        req = Request(ServerUrl.ent_batch_query_upload_url,data=data,files=file_data,headers=cookie)
        return req.post()

    @classmethod
    def get_page(cls,curPage,
                    maxSize,
                    search_EQ_queryid,
                    search_EQ_userid,
                    search_EQ_username,
                    search_GTE_LTE_queryTime_DATE_RANGE,
                    search_IN_organ,
                    search_operOrgRange,
                    search_EQ_errornum,cookie):

        data = {
            'curPage':curPage,
            'maxSize':maxSize,
            'search_EQ_queryid':search_EQ_queryid,
            'search_EQ_userid':search_EQ_userid,
            'search_EQ_username':search_EQ_username,
            'search_GTE_LTE_queryTime_DATE_RANGE':search_GTE_LTE_queryTime_DATE_RANGE,
            'search_IN_organ':search_IN_organ,
            'search_operOrgRange':search_operOrgRange,
            'search_EQ_errornum':search_EQ_errornum
        }
        req = Request(ServerUrl.per_batch_query_getpage_url,params=data,headers=cookie)
        return req.get()

    @classmethod
    def down_error(cls,queryid,cookie):
        data = {
            'queryid':queryid
        }
        req = Request(ServerUrl.ent_batch_query_error_url,params=data,headers=cookie)
        return req.get_download()

    @classmethod
    def jump(cls,authType,cookie):
        data = {
            'authType':authType
        }
        req = Request(ServerUrl.ent_batch_query_jump_url,data=data,headers=cookie)
        return req.post()








if __name__ == "__main__":
    pass